using System;
using System.Windows.Forms;
using System.Drawing;

namespace monoServer
{
	public class LoginWindow : Form
	{
		private TableLayoutPanel tlp;
		private Label lbl_nickname;
		private TextBox tb_nickname;
		private Label lbl_password;
		private TextBox tb_password;
		public Button btn_login;
		private Label lbl_error;
		
		public string userName
		{
			get {
				return this.tb_nickname.Text;
			}
		}
		
		public string userPassword
		{
			get {
				return this.tb_password.Text;
			}
		}
		
		public LoginWindow (int width, int height)
		{
			this.Width = width;
			this.Height = height;
			
			this.tlp = new TableLayoutPanel();
			this.tlp.Size = new Size(this.Width, this.Height);
			this.tlp.RowCount = 4;
			this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 15));
			this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 15));
			this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 15));
			this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 15));
			this.tlp.ColumnCount = 2;
			this.tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
			this.tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
			this.tlp.BorderStyle = BorderStyle.FixedSingle;
						
			this.lbl_nickname = new Label();
			this.lbl_nickname.Text = "Benutzername:";
			this.lbl_nickname.Font = new Font("Arial", 11);
			this.lbl_nickname.Anchor = AnchorStyles.None;
			
			this.tb_nickname = new TextBox();
			this.tb_nickname.Anchor = AnchorStyles.None;
			
			this.lbl_password = new Label();
			this.lbl_password.Text = "Passwort:";
			this.lbl_password.Font = new Font("Arial", 11);
			this.lbl_password.Anchor = AnchorStyles.None;
			
			this.tb_password = new TextBox();
			this.tb_nickname.Anchor = AnchorStyles.None;
			
			this.btn_login = new Button();
			this.btn_login.Text = "Anmelden";
			this.btn_login.Anchor = AnchorStyles.None;
			this.btn_login.Font = new Font("Arial", 11);

			this.lbl_error = new Label();
			this.lbl_error.Anchor = AnchorStyles.None;
			this.lbl_error.Text = "##############";
			
			this.tlp.Controls.Add(this.lbl_nickname, 0, 0);
			this.tlp.Controls.Add(this.tb_nickname, 1, 0);
			this.tlp.Controls.Add(this.lbl_password, 0, 1);
			this.tlp.Controls.Add(this.tb_password, 1, 1);
			this.tlp.Controls.Add(this.btn_login, 0, 2);
			this.tlp.Controls.Add(this.lbl_error, 0, 3);
			
			this.tlp.SetColumnSpan(this.btn_login, 2);
			this.tlp.SetColumnSpan(this.lbl_error, 2);
			this.Controls.Add(this.tlp);
		}
		
		public void setErrorMsg(string msg)
		{
			this.lbl_error.Text = msg;
		}
		
		public void resetFormular()
		{
			this.tb_nickname.Text = string.Empty;
			this.tb_password.Text = string.Empty;
		}
		
		/*
		public void hide()
		{
		}
		
		public void show()
		{
		}
		*/
	}
}

